package webreg.model.container;

import java.util.Iterator;
import java.util.Vector;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import webreg.model.AgeTable;


/** This class wraps multiple 
 * age tables in one container class for persistence.
 * 
 * @author STKNOLL
 */
@XmlRootElement(name = "ageTableContainer")
public class AgeTableContainer {

	/** Vector containing the age tables */
	@XmlElement(name = "AgeTable")
	private Vector<AgeTable> mAgeTables;

	/** Constructor of an age table container */
	public AgeTableContainer() {
		mAgeTables = new Vector<AgeTable>();
	}
	
	/** Constructor of an age table container
	 * 
	 * @param tables The age tables to store.
	 */
	public AgeTableContainer(Vector<AgeTable> tables) {
		mAgeTables = tables;
	}
	
	/** Copy constructor for age table container
	 * 
	 * Private copy constructor for an age table container
	 * 
	 * @param toCopy The age table container to copy
	 */
	public AgeTableContainer (AgeTableContainer toCopy) {
		this(toCopy.mAgeTables);
	}
	
	/** Implementation of the equals method.
	 * 
	 * @param toCompare The age table container to compare with
	 * @return True, if age table matches
	 */
	public boolean equals(AgeTableContainer toCompare) {
		Iterator<AgeTable> iter = this.mAgeTables.iterator();
		Iterator<AgeTable> iter2 = toCompare.mAgeTables.iterator();
		for (; iter.hasNext() && iter2.hasNext(); ) {
			AgeTable ageTable1 = (AgeTable)iter.next();
			AgeTable ageTable2 = (AgeTable)iter2.next();
			if (ageTable1.equals(ageTable2) == false) return false;
		}
		return true;
	}

	
	
	
	/** Sets the age tables that are stored in the container
	 * 
	 * @param tables The tables to hold in the container
	 */
	public void setAgeTables(Vector<AgeTable> tables) {
		mAgeTables = tables;
	}

	/** Gets the stored age tables of the container
	 * 
	 * @return The age tables stored in the container.
	 */
	public Vector<AgeTable> getAgeTables() {
		return mAgeTables;
	}
}
